<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>How does the currency look like? - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.currency.number.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.currency.number.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.currency.position.html">Where is the currency?</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.currency.html">Zend_Currency</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.currency.value.html">How much is my currency?</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.currency.number" class="section"><div class="info"><h1 class="title">How does the currency look like?</h1></div>
    

    <p class="para">
        How the value of a currency will be rendered depends mainly on the used locale. There
        are several informations which are set by the locale. Each of them can manually be
        overridden by using the proper option.
    </p>

    <p class="para">
        For example, most locales are using the Latin script for rendering numbers. But there
        are languages like &quot;Arabic&quot; which are using other digits. And when you have an Arabic
        website you may also want to render other currencies by using the Arabic script. See
        the following example:
    </p>

    <div class="example" id="zend.currency.number.example-1"><div class="info"><p><b>Example #1 Using a custom script</b></p></div>
        

        <div class="example-contents"><p>
            Let&#039;s expect that we are again using our &quot;Dollar&quot; currency. But now we want to
            render our currency by using the Arabic script.
        </p></div>

        <pre class="programlisting brush: php">
$currency = new Zend_Currency(
    array(
        &#039;value&#039;  =&gt; 1000,
        &#039;script&#039; =&gt; &#039;Arab&#039;,
    )
);

print $currency; // Could return &#039;$ ١٬٠٠٠٫٠٠&#039;
</pre>

    </div>

    <p class="para">
        For more informations about available scripts look into
        <span class="classname">Zend_Locale</span>&#039;s <a href="zend.locale.parsing.html#zend.locale.numbersystems" class="link">chapter
            about numbering systems</a>.
    </p>

    <p class="para">
        But also the formatting of a currency number (money value) can be changed. Per default
        it depends on the used locale. It includes the separator which will be used between
        thousands, which sign will be used as decimal point, and also the used precision.
    </p>

    <pre class="programlisting brush: php">
$currency = new Zend_Currency(
    array(
        &#039;value&#039;    =&gt; 1000,
        &#039;currency&#039; =&gt; &#039;USD&#039;
        &#039;format&#039;   =&gt; &#039;de&#039;,
    )
);

print $currency; // Could return &#039;$ 1.000&#039;
</pre>


    <p class="para">
        There are two ways to define the format which will be used. You can either give a
        locale or define a format manually.
    </p>

    <p class="para">
        When you are using a locale for defining the format all is done automatically. The
        locale &#039;de&#039;, for example, defines &#039;.&#039; as separator for thousands and &#039;,&#039; as decimal
        point. Within English this is reversed.
    </p>

    <pre class="programlisting brush: php">
$currency_1 = new Zend_Currency(
    array(
        &#039;value&#039;    =&gt; 1000,
        &#039;currency&#039; =&gt; &#039;USD&#039;
        &#039;format&#039;   =&gt; &#039;de&#039;,
    )
);

$currency_2 = new Zend_Currency(
    array(
        &#039;value&#039;    =&gt; 1000,
        &#039;currency&#039; =&gt; &#039;USD&#039;
        &#039;format&#039;   =&gt; &#039;en&#039;,
    )
);

print $currency_1; // Could return &#039;$ 1.000&#039;
print $currency_2; // Could return &#039;$ 1,000&#039;
</pre>


    <p class="para">
        When you define it manually then you must conform the format as described in
        <a href="zend.locale.parsing.html#zend.locale.number.localize.table-1" class="link">this chapter about
            localizing</a>. See the following:
    </p>

    <pre class="programlisting brush: php">
$currency = new Zend_Currency(
    array(
        &#039;value&#039;    =&gt; 1000,
        &#039;currency&#039; =&gt; &#039;USD&#039;
        &#039;format&#039;   =&gt; &#039;#0&#039;,
    )
);

print $currency; // Could return &#039;$ 1000&#039;
</pre>


    <p class="para">
        In the above snippet we deleted the separator and also the precision.
    </p>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.currency.position.html">Where is the currency?</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.currency.html">Zend_Currency</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.currency.value.html">How much is my currency?</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.currency.html">Zend_Currency</a></li>
  <li><a href="zend.currency.introduction.html">Introduction to Zend_Currency</a></li>
  <li><a href="zend.currency.usage.html">Using Zend_Currency</a></li>
  <li><a href="zend.currency.options.html">Options for currencies</a></li>
  <li><a href="zend.currency.description.html">What makes a currency?</a></li>
  <li><a href="zend.currency.position.html">Where is the currency?</a></li>
  <li class="active"><a href="zend.currency.number.html">How does the currency look like?</a></li>
  <li><a href="zend.currency.value.html">How much is my currency?</a></li>
  <li><a href="zend.currency.calculation.html">Calculating with currencies</a></li>
  <li><a href="zend.currency.exchange.html">Exchanging currencies</a></li>
  <li><a href="zend.currency.additional.html">Additional informations on Zend_Currency</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>